# coding:utf-8
"""
Author: 11203
Date:  23:32
Name: __init__.py
"""
from flask import Flask


from settings import map_config



# 创建Flask配置信息
def create_app(config_key):
    app = Flask(__name__, template_folder='templates')
    app.config.from_object(map_config.get(config_key))
    # 加载日志处理工具
    # 初始数据库连接(SqlAlchemy)

    # 加载此处，则所有的请求都有当前的请求钩子.
    from common.others import request_wares
    app.before_request(request_wares.jwt_request_authorization)

    # 加载模块蓝图
    # --- 用户蓝图 ---
    from shopping.resources.user import users_bp
    app.register_blueprint(users_bp)

    return app